<?php
/**
 * Author：晴天 QQ：1186258278
 * Creation：2020/7/10 22:48
 * Filename：admin.store.php
 * 应用商店
 */

$title = '应用商店';
include "header.php";

?>

<div id="app">
    <div class="layui-fluid" style="padding: 0;">
        <div class="layui-tab" v-if="AppType==1">
            <!-- 分类模块 -->
            <ul class="layui-tab-title" style="margin-bottom: 0;">
                <li v-for="(item,index) in TypeList" :key="index" v-bind:class="type==index?'layui-this':''"
                    v-on:click="TypeOn(index)">{{ item.name }}
                </li>
            </ul>
            <!-- 分类模板end -->
            <form>
                <div class="input-group">
                    <input type="text" class="form-control" v-model="Search" placeholder="直接输入应用名称搜索!">
                    <div class="input-group-append">
                        <button class="btn btn-primary" v-on:click="refresh" type="button">搜索
                        </button>
                    </div>
                </div>
            </form>

            <div class="layui-tab-content pt-0">
                <div v-for="(item,index) in TypeList" :key="index"
                     v-bind:class="type==index?'layui-tab-item layui-show':'layui-tab-item'">

                    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                        <!-- 子分类模块 -->
                        <ul class="layui-tab-title">
                            <li
                                    v-for="(item2,index2) in SortTypeList[index]" :key="index2"

                                    v-bind:class="SortType[index]==index2?'layui-this':''"

                                    v-on:click="SortTypeOn(index2)" style="font-size: 0.9rem !important;">{{ item2.name
                                }}
                            </li>
                        </ul>
                        <!-- 子分类模块end -->

                    </div>
                    <!-- 内容模块 -->
                    <div class="layui-row layui-col-space12" v-if="ListData[type].length>=1">
                        <div v-for="(item2,index2) in ListData[index]"
                             class="layui-col-xs6 layui-col-sm4 layui-col-md3 layui-col-lg2" :title="item2.content">
							 
							<div class="layui-card text-center card-q">
								
								<div v-if="item2.load==true" class="Loadings">
									<i class="layui-icon layui-anim layui-anim-rotate layui-anim-loop" style="font-size: 0.3em;">&#xe63e;</i>
								</div>
								
								<div class="layui-card-body" style="background-color: #fff;">
									<!-- 左上角状态模块 -->
									<div v-if="item2.state == 1" class="u-close badge-success">已购</div>
									<div v-if="item2.state == 2" class="u-close badge-danger">到期</div>
									<div v-if="item2.state == 3" class="u-close badge-warning" title="剩余使用时间不足">不足</div>
									
									<div v-if="item2.install_state == 1&&item2.state>=1&&item2.state!=2" class="u-close ml-4 badge-danger" v-on:click="unload(item2.identification,item2.title,index2)">卸载</div>
									
									<div v-on:click="state(item2.identification,2,index2)" v-if="item2.install_state == 1&&item2.state>=1&&item2.state!=2&&item2.run_state==1" class="u-close badge-success mt-4">启用中</div>
									<div v-on:click="state(item2.identification,1,index2)" v-if="item2.install_state == 1&&item2.state>=1&&item2.state!=2&&item2.run_state!=1" class="u-close badge-danger mt-4">已停用</div>
									
									<div v-if="item2.Hover == 1&&item2.state>=1&&item2.state!=2&&item2.run_state==1" class="u-close badge-danger" style="margin-top: 4.5rem;" @click="Hover(item2.identification,'HoverOff')">关闭悬停</div>
									<div v-if="item2.Hover == -1&&item2.state>=1&&item2.state!=2&&item2.run_state==1" class="u-close badge-success" style="margin-top: 4.5rem;" @click="Hover(item2.identification,'HoverOn')">开启悬停</div>
									
									<!-- 左上角状态模块end -->
									<img :src="item2.image" v-on:click="explain(item2.title,item2.content)" style="width: 8em;height: 8em;" />
									
									<span v-on:click="Update(item2.id, item2.versions, item2.update_instructions,index2)" v-if="item2.install_state == 1&&item2.state>=1&&item2.state!=2&&item2.versions_state==1" class="uodate-q badge-warning">升级</span>
								</div>
								<div class="layui-card-header pb-1" style="text-align: left;height: auto;line-height: 1.9em;">
									<div class="w-100 layui-elip font-18" :title="item2.title">{{ item2.title }}</div>
									
									<div class="text-left" style="height: 1.6em;">
										<div class="demo-price layui-elip" style="color: #18B566;" v-if="item2.price == 0">免费</div>
										<div class="demo-price layui-elip" v-if="item2.discounts == 10 && item2.price != 0">
											<span style="font-size: 1rem;">￥{{ item2.price }}</span>
										</div>
										<div class="demo-price  layui-elip" v-if="item2.discounts != 10 && item2.price != 0">
											<span style="font-size: 1rem;">￥{{ item2.price }}</span>
											<span style="color: #acacac;font-size: 0.7rem;" class="ml-1">￥{{ item2.money }}</span>
										</div>
									</div>
									
									<div class="text-left mt-1">
										<span class="layui-badge mr-1 badge-success-lighten"style="border-radius: 0.2em;">{{ item2.grade }}级应用</span>
									<span v-if="item2.type == 1" class="layui-badge badge-warning-lighten" style="border-radius: 0.2em;">插件</span>
									<span v-if="item2.type == 2" class="layui-badge badge-danger-lighten"style="border-radius: 0.2em;">模板</span>
									</div>
									<div class="text-gray font-13 mb-1">
										开发者：{{ item2.shop }} / <span>{{ item2.score==0?'无评':item2.score }}分</span>
									</div>
									<div class="layui-btn-group w-100">
										<button v-on:click="pay(item2.id,item2.price,item2.title,index2)" v-if="item2.state == -1" type="button" class="layui-btn layui-btn-sm btn-success">
										  <i class="layui-icon">&#xe68d;</i> 购买应用 / 30天
										</button>
										<button v-on:click="prolong(item2.id,item2.title,index2)" v-if="item2.state >= 1" type="button" class="layui-btn layui-btn-sm btn-info">
										  续期
										</button>
										<button v-if="item2.install_state != 1&&item2.state>=1&&item2.state!=2" type="button" class="layui-btn layui-btn-sm btn-primary" v-on:click="install(item2.id,item2.title,index2)">
										  安装应用
										</button>
										<button v-on:click="iframeOn(1,item2.identification,item2.id,item2.title)" v-if="item2.state >= 1&&item2.state != 2&&item2.install_state == 1" type="button" class="layui-btn layui-btn-sm btn-primary">
										  <i class="layui-icon">&#xe716;</i>
										</button>
										<button v-on:click="iframeOn(2,item2.identification,item2.id,item2.title)" v-if="item2.state >= 1&&item2.state != 2&&item2.install_state == 1" type="button" class="layui-btn layui-btn-sm btn-warning">
										  <i class="layui-icon">&#xe705;</i>
										</button>
									</div>
								</div>
							</div>
                        </div>
                    </div>

                    <div style="text-align: center;width: 100%;margin: 1.6rem 0;" v-if="statr[type]==true">
                        <button v-on:click="LoadMore" class="layui-btn layui-btn-primary layui-btn-radius">加载更多</button>
                    </div>

                    <div style="text-align: center;width: 100%;margin: 1.6rem 0;"
                         v-if="statr[type]==false&&ListData[type].length!=0">
                        <button class="layui-btn layui-btn-disabled layui-btn-radius">到底了</button>
                    </div>

                    <div v-if="ListData[type].length==0"
                         style="text-align: center;font-size: 1.3em;color: #939393;margin: 2em;">
                        {{ Search==''?'空空如也':'没有查找名称带有['+Search+']的应用！' }}
                    </div>
                    <!-- 内容模块end -->
                </div>
            </div>
			<div v-on:click="GlobalRefresh" class="GlobalRefresh">
				<i class="layui-icon layui-icon-refresh-3" style="font-size: 1em;"></i>
			</div>
			<div v-on:click="Grade" class="GlobalRefresh" style="margin-top: -2.8em;background-color:#535353">
				<img src="../assets/img/Grade.png" width="80%" height="80%" />
			</div>
        </div>
		<div v-if="AppType==2">
			<div v-on:click="iframeOn(3)" class="title text-amber layui-elip" title="返回"><i class="layui-icon layui-icon-left mr-1" style="font-size: 1em;"></i>{{ title }}</div>
			<iframe :src="iframe[0]" class="iframes"></iframe>
		</div>
		<div v-if="AppType==3">
			<div v-on:click="iframeOn(3)" class="title text-warning layui-elip" title="返回"><i class="layui-icon layui-icon-left mr-1" style="font-size: 1em;"></i>{{ title }}</div>
			<iframe :src="iframe[1]" class="iframes"></iframe>
		</div>
    </div>
</div>
<style lang="scss" scoped>
.GlobalRefresh {
	position: fixed;
	top: 40vh;
	right: 1em;
	width: 2em;
	height: 2em;
	background-color: #5500ff;
	color: white;
	font-size: 1.2em;
	border-radius: 30em;
	text-align: center;
	line-height: 2em;
	z-index: 6666;
	box-shadow: 3px 3px 16px #ababab;
}
.title {
	width: 100%;
	height: 2em;
	font-size: 1.5em;
	margin-top: 1em;
}
.iframes {
	width: 100%;
	min-height: 67.5vh;
	border: none;
	box-shadow: 3px 3px 16px #eee;
}
.Loadings {
	position: absolute;
	width: 96%;
	height: 96%;
	background-color: rgba(0, 0, 0, 0.7);
	color: #fff;
	z-index: 10;
	line-height: 2.2;
	font-size: 6em;
	border-radius: 0.1em;
}
.card-q {
	box-shadow: 3px 3px 16px #f5f5f5;
	border-radius: 0.3em;
	overflow: hidden;
	transition: all 0.3s;
}
.card-q:hover {
	box-shadow: 3px 3px 16px 3px #47e7d5;
}
.uodate-q {
	position: absolute;
	right: 5px;
	top: 32rpx;
	border-radius: 0.2rem;
	padding: 0rem 0.3rem;
	color: #fff;
	font-size: 0.5rem;
	box-shadow: 3px 3px 16px #ccc;
}
.demo-price {
	font-size: 30rpx;
	color: red;
	margin-top: 5px;
}
.u-close {
	position: absolute;
	top: 32rpx;
	border-radius: 0.2rem;
	left: 5px;
	padding: 0rem 0.3rem;
	color: #fff;
	font-size: 0.5rem;
	box-shadow: 3px 3px 16px #ccc;
}
</style>
<?php include "bottom.php"; ?>

<script>
var vm = new Vue({
	el: '#app',
	data: {
		ListData: [[], [], [], []],
		limit: 8,
		page: [1, 1, 1, 1],
		SortType: [0, 0, 0, 0],
		type: 0,
		Search: '',
		Searche: '',
		SortTypeList: [],
		TypeList: [
			{
				name: '全部'
			},
			{
				name: '插件'
			},
			{
				name: '模板'
			},
			{
				name: '我的'
			}
		],
		scrollTop: 0,
		statr: [true, true, true, true],
		grounding: [true, true, true, true],
		time: 388,
		AppType: 1,
		iframe: ['', ''],
		title: '',
		scrollTopApp: 0,
	},
	destroyed() {
		// 离开该页面需要移除这个监听的事件，不然会报错
		window.removeEventListener('scroll', this.handleScroll);
	},
	methods: {
		iframeOn(type, identification = '', id = '', title = '') {
			if (type == 1) {
				this.scrollTopApp = this.scrollTop;
				this.iframe[0] = 'ajax.php?act=app_view&id=' + identification + '&path=index&t=' + id;
				this.AppType = 2;
				this.title = title + ' - 操作面板';
				$('.AppOn').hide();
				$('html , body').animate({ scrollTop: 0 }, 200);
			} else if (type == 2) {
				this.scrollTopApp = this.scrollTop;
				this.iframe[1] = 'ajax.php?act=app_help&id=' + identification;
				this.AppType = 3;
				this.title = title + ' - 使用说明';
				$('.AppOn').hide();
				$('html , body').animate({ scrollTop: 0 }, 200);
			} else {
				$('html , body').animate({ scrollTop: this.scrollTopApp }, 200);
				this.iframe = ['', ''];
				this.AppType = 1;
				$('.AppOn').show();
			}
		},
		partialRefresh(index = -1) {
			if (index == -1) {
				this.page[this.type] = 1;
				this.grounding[this.type] = true;
				this.ListData[this.type] = [];
			} else {
				this.ListData[this.type][index].load = true;
				this.$forceUpdate();
			}
			this.statr[this.type] = true;
			setTimeout(() => {
				this.AjaxList(4, index);
			}, 888);
		},

		GlobalRefresh() {
			let _this = this;
			layer.open({
				title: '操作确认',
				content: '是否要从服务端获取最新数据，这将会刷新应用列表?',
				btn: ['确定', '取消'],
				icon: 3,
				btn1: function(layero, index) {
					layer.msg('获取中', { icon: 16, time: 9999999 });
					$.ajax({
						type: 'post',
						url: 'ajax.php?act=GlobalRefresh',
						dataType: 'json',
						success: function(data) {
							layer.closeAll();
							if (data.code >= 0) {
								layer.msg(data.msg, { icon: 1 });
								_this.partialRefresh(-1);
							} else {
								layer.msg(data.msg, { icon: 2 });
							}
						},
						error: function() {
							layer.closeAll();
							layer.alert('购买失败！');
						}
					});
				}
			});
		},

		pay(id, price, name, key) {
			let _this = this;
			layer.open({
				title: '操作确认',
				content: '是否要购买：' + name + '30天使用权？<br>这将会花费您' + price + '元服务端余额,请确保余额充足！',
				btn: ['购买', '取消'],
				icon: 3,
				btn1: function(layero, index) {
					_this.ListData[_this.type][key].load = true;
					_this.$forceUpdate();
					$.ajax({
						type: 'post',
						url: 'ajax.php?act=app_pay&id=' + id,
						dataType: 'json',
						success: function(data) {
							layer.closeAll();
							if (data.code >= 0) {
								_this.partialRefresh(key);
								layer.alert(data.msg, { icon: 1 });
							} else {
								_this.ListData[_this.type][key].load = false;
								_this.$forceUpdate();
								layer.msg(data.msg, { icon: 2 });
							}
						},
						error: function() {
							_this.ListData[_this.type][key].load = false;
							_this.$forceUpdate();
							layer.alert('购买失败！');
						}
					});
				}
			});
		},
		Hover(id, type) {
			let _this = this;
			$.ajax({
				type: 'post',
				url: 'ajax.php?act=' + type,
				data: {
					id: id
				},
				dataType: 'json',
				success: function(data) {
					if (data.code >= 0) {
						layer.alert(data.msg, {
							icon: 1,
							end: function(layero, index) {
								location.reload();
							}
						});
					} else {
						layer.msg(data.msg, { icon: 2 });
					}
				},
				error: function() {
					_this.ListData[_this.type][key].load = false;
					_this.$forceUpdate();
					layer.alert('操作失败！');
				}
			});
		},
		Grade() {
			layer.load(1, { time: 999999 });
			let _this  = this;
			$.ajax({
				type: 'POST',
				url: 'ajax.php?act=app_users',
				async: true,
				dataType: 'json',
				success: function(res) {
					layer.closeAll();
					if (res.code >= 0) {
						let content = `
						<div class="layui-card" style="width:250px">
						  <div class="layui-card-body">
						  <ul class="layui-timeline">
						  <li class="layui-timeline-item">
						    <i class="layui-icon layui-timeline-axis">&#xe65e;</i>
						    <div class="layui-timeline-content layui-text">
						      <h3 class="layui-timeline-title">账户余额：`+res.money+` 元</h3>
						    </div>
						  </li>
						    <li class="layui-timeline-item">
						      <i class="layui-icon layui-timeline-axis">&#xe735;</i>
						      <div class="layui-timeline-content layui-text">
						        <h3 class="layui-timeline-title">账户等级：`+res.grade+` 级</h3>
						      </div>
						    </li>
							<li class="layui-timeline-item">
							  <i class="layui-icon layui-timeline-axis">&#xe609;</i>
							  <div class="layui-timeline-content layui-text">
							    <h3 class="layui-timeline-title">升级还差：`+res.demand+`</h3>
							  </div>
							</li>
						    <li class="layui-timeline-item">
						      <i class="layui-icon layui-timeline-axis">&#xe756;</i>
						      <div class="layui-timeline-content layui-text">
						        <div class="layui-timeline-title">当前总成长值：`+res.present+`</div>
						      </div>
						    </li>
						  </ul>
						  Ps：成长值可通过每日签到或活动产出，余额充值请前往小程序，或app，或<a href="http://h5.api.ln.cn/" >h5</a>控制端充值
						  </div>
						</div>
						`;
						layer.open({
							type:1,
							title:'我的账户',
							content:content,
							btn:['关闭窗口'],
							btnAlign: 'c'
						});
						
					} else layer.msg(res.msg);
				}
			});
		},
		prolong(id, name, key) {
			let _this = this;
			layer.open({
				title: '操作确认',
				content: '是否要为' + name + '延长到期时间?',
				btn: ['确认', '取消'],
				icon: 3,
				btn1: function(layero, index) {
					_this.ListData[_this.type][key].load = true;
					_this.$forceUpdate();
					$.ajax({
						type: 'post',
						url: 'ajax.php?act=app_prolong&id=' + id,
						dataType: 'json',
						success: function(data) {
							if (data.code >= 0) {
								_this.partialRefresh(key);
								layer.alert(data.msg, { icon: 1 });
							} else {
								_this.ListData[_this.type][key].load = false;
								_this.$forceUpdate();
								layer.msg(data.msg, { icon: 2 });
							}
						},
						error: function() {
							_this.ListData[_this.type][key].load = false;
							_this.$forceUpdate();
							layer.alert('操作失败！');
						}
					});
				}
			});
		},
		state(id, type, key) {
			let _this = this;
			this.ListData[_this.type][key].load = true;
			this.$forceUpdate();
			$.ajax({
				type: 'post',
				url: 'ajax.php?act=app_state_set&id=' + id + '&type=' + type,
				dataType: 'json',
				success: function(data) {
					layer.closeAll();
					if (data.code >= 0) {
						_this.partialRefresh(key);
						//layer.msg(data.msg, { icon: 1 });
					} else {
						_this.ListData[_this.type][key].load = false;
						_this.$forceUpdate();
						layer.msg(data.msg, { icon: 2 });
					}
				},
				error: function() {
					_this.ListData[_this.type][key].load = false;
					_this.$forceUpdate();
					layer.alert('切换失败！');
				}
			});
		},
		install(id, name, key) {
			let _this = this;
			layer.open({
				title: '操作确认',
				content: '是否要安装' + name + '？',
				btn: ['安装', '取消'],
				icon: 3,
				btn1: function(layero, index) {
					layer.closeAll();
					_this.ListData[_this.type][key].load = true;
					_this.$forceUpdate();
					$.ajax({
						type: 'post',
						url: 'ajax.php?act=app_install&id=' + id + '&type=1',
						dataType: 'json',
						success: function(data) {
							if (data.code >= 0) {
								_this.partialRefresh(key);
								//layer.msg(data.msg, { icon: 1 });
							} else {
								_this.ListData[_this.type][key].load = false;
								_this.$forceUpdate();
								layer.msg(data.msg, { icon: 2 });
							}
						},
						error: function() {
							_this.ListData[_this.type][key].load = false;
							_this.$forceUpdate();
							layer.msg('应用安装失败，返回异常，请检查您的服务器是否支持：ZipArchive操作类！');
						}
					});
				}
			});
		},
		unload(identification, name, key) {
			let _this = this;
			layer.open({
				title: '操作确认',
				content: '是否要卸载' + name + '？<br>卸载后将无法使用此应用,若要使用需要再次安装!',
				btn: ['确认', '取消'],
				icon: 3,
				btn1: function(layero, index) {
					layer.closeAll();
					_this.ListData[_this.type][key].load = true;
					_this.$forceUpdate();
					$.ajax({
						type: 'post',
						url: 'ajax.php?act=app_unload&id=' + identification,
						dataType: 'json',
						success: function(data) {
							layer.closeAll();
							if (data.code >= 0) {
								_this.partialRefresh(key);
								layer.alert(data.msg, { icon: 1 });
							} else {
								_this.ListData[_this.type][key].load = false;
								_this.$forceUpdate();
								layer.msg(data.msg, { icon: 2 });
							}
						},
						error: function() {
							_this.ListData[_this.type][key].load = false;
							_this.$forceUpdate();
							layer.alert('卸载失败！');
						}
					});
				}
			});
		},
		Update(id, versions, update_instructions, key) {
			let _this = this;
			layer.open({
				title: 'v' + versions + ' 更新日志',
				content: update_instructions,
				btn: ['更新', '取消'],
				btn1: function(layero, index) {
					layer.closeAll();
					_this.ListData[_this.type][key].load = true;
					_this.$forceUpdate();
					$.ajax({
						type: 'post',
						url: 'ajax.php?act=app_install&id=' + id + '&type=2',
						dataType: 'json',
						success: function(data) {
							if (data.code >= 0) {
								_this.partialRefresh(key);
								//layer.msg(data.msg, { icon: 1 });
							} else {
								_this.ListData[_this.type][key].load = false;
								_this.$forceUpdate();
								layer.msg(data.msg, { icon: 2 });
							}
						},
						error: function() {
							_this.ListData[_this.type][key].load = false;
							_this.$forceUpdate();
							layer.alert('更新失败！');
						}
					});
				}
			});
		},
		explain(title, content = '') {
			layer.alert(content, { title: title, shade: [0.8, '#393D49'], shadeClose: true });
		},
		LoadMore() {
			if (this.Search == '' && this.Searche == this.Search) {
				this.grounding[this.type] = false;
				if (this.ListData[this.type].length >= 1) {
					++this.page[this.type];
				}
				this.AjaxList(1);
			} else {
				this.refresh();
			}
		},
		handleScroll() {
			this.scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
			if (this.grounding[this.type] == false) return;
			var viewH = $(window).height(); //可见高度
			var contentH = $(document).height(); //内容高度

			if (contentH - (this.scrollTop + viewH) <= viewH / 6) {
				this.grounding[this.type] = false;
				++this.page[this.type];
				this.AjaxList(1);
			}
		},

		/**
		 * @param {Object} index
		 * 调整应用类型
		 */
		TypeOn(index) {
			this.type = index;
			if (this.ListData[this.type].length == 0) {
				this.AjaxList();
			}
		},
		SortTypeOn(index) {
			this.page[this.type] = 1;
			this.statr[this.type] = true;
			this.grounding[this.type] = true;
			this.ListData[this.type] = [];
			this.SortType[this.type] = index;
			this.AjaxList();
		},
		AjaxList(type = 2, key = -1) {
			if (type != 4) layer.load(2);
			let _this = this;

			let SortType = _this.SortType[_this.type];
			let page = _this.page[_this.type];
			let Search = _this.Search;

			if (_this.statr[_this.type] == false) {
				layer.closeAll();
				if (type == 1) {
					_this.page[_this.type] = page - 1;
					return;
				}
			}

			if (type == 4 && key != -1) {
				/**
				 * 方法一
				 * 获取指定key的页码
				 * 简单算法
				 */

				// if (key <= this.limit) {
				// 	page = 1;
				// } else {
				// 	let Count = key / this.limit;
				// 	if (Count % 1 === 0) {
				// 		page = Count + 1;
				// 	} else {
				// 		page = Math.floor(Count) + 1;
				// 	}
				// }

				/**
				 * 方法二
				 * 查询指定数据可减缓服务器压力
				 */
				Search = this.ListData[_this.type][key].title;
				page = 1;
			}

			$.ajax({
				type: 'POST',
				url: 'ajax.php?act=ApplyList',
				async: true,
				data: {
					page: page,
					limit: _this.limit,
					SortType: SortType,
					type: _this.type,
					Search: Search
				},
				dataType: 'json',
				success: function(data) {
					layer.closeAll();
					if (type == 4 && key != -1) {
						/**
						 * 局部刷新 key值
						 * 取出的是页码内的数据，
						 */
						if (data.code >= 0) {
							let id = _this.ListData[_this.type][key].id;
							for (let i = 0; i < data.data.length; i++) {
								if (data.data[i].id == id) {
									_this.ListData[_this.type][key] = data.data[i];
									_this.$forceUpdate();
									return;
								}
							}
							_this.partialRefresh();
						} else layer.alert(data.msg, { icon: 2, title: '警告' });
						return;
					}

					if (data.code >= 0) {
						_this.Searche = _this.Search;
						if (data.SortTypeList.length > 0) {
							_this.SortTypeList[_this.type] = data.SortTypeList;
						}

						if (data.data.length < _this.limit) {
							_this.statr[_this.type] = false;
						} else {
							_this.grounding[_this.type] = true;
							_this.statr[_this.type] = true;
						}

						let time = _this.time / data.data.length;

						for (let i = 0; i < data.data.length; i++) {
							setTimeout(() => {
								_this.ListData[_this.type].push(data.data[i]);
								_this.$forceUpdate();
							}, time * i);
						}

						setTimeout(() => {
							_this.$forceUpdate();
						}, _this.time);
					} else if (data.code == -2) {
						if (type == 1) {
							_this.page[_this.type] = page - 1;
						} else if (type == 2) _this.page[_this.type] = page;

						_this.grounding[_this.type] = true;
						_this.statr[_this.type] = true;

						//layer.alert(data.msg, { icon: 2, title: '警告' });
					} else layer.alert(data.msg, { icon: 2, title: '警告' });
				},
				error: function() {
					layer.close(index);
					layer.alert('用户数据获取失败！');
				}
			});
		},
		//搜索
		refresh() {
			this.statr[this.type] = true;
			this.grounding[this.type] = true;
			this.ListData[this.type] = [];
			this.page[this.type] = 1;
			this.AjaxList(3);
		}
	},
	mounted() {
		this.AjaxList();
		window.addEventListener('scroll', this.handleScroll, true);
	}
});

layui.use('util', function() {
	var util = layui.util;

	//执行
	util.fixbar({
		bar1: false
	});
});
</script>
